package org.wak.scene.events
{
	
	import flash.events.Event;
	
	import org.wak.scene.ISceneInteractable;

	/**
	 * Events coming from the scene. 
	 * 
	 */	
	public class SceneEvent extends Event
	{
		/**
		 * Dispatched when an ISceneInteractable item is clicked on the scene. 
		 */		
		public static const SCENEITEM_CLICK:String = "sceneitem_click";
		
		
		/**
		 * Dispatched when a void space on the scene was clicked 
		 */		
		public static const SCENE_SPACE_CLICK:String = "scene_space_click";
		
		/**
		 * Dispatched when a mouse over was made over an ISceneInteractable
		 */		
		public static const SCENEITEM_MOUSEOVER:String = "sceneitem_mouseover";
		
		/**
		 * Dispatched when a mouse out was made over an ISceneInteractable 
		 */		
		public static const SCENEITEM_MOUSEOUT:String = "sceneitem_mouseout";
		
		/**
		 * Dispatched when the player's character enters to the scene. 
		 */		
		public static const ENTER_SCENE:String = "enter_scene";
		
		/**
		 * Dispatched when the player's character exits the scene. 
		 */		
		public static const EXIT_SCENE:String = "exit_scene";
		
		
		
		private var mInteractable:ISceneInteractable = null ;
		
		// the scene id where the event came from.
		private var mSceneId:String = "" ;
		
		private var mLocalX:Number ;
		
		private var mLocalY:Number ;
		
		private var mCtrlKey:Boolean ;
		
		private var mAltKey:Boolean ;
		
		private var mShiftKey:Boolean ;
		
		private var mSceneMouseX:Number ;
		
		private var mSceneMouseY:Number ;
		
		
		public function SceneEvent(type:String, pTarget:Object, pSceneId:String, bubbles:Boolean = true, cancelable:Boolean = false, localX:Number = NaN, localY:Number = NaN, ctrlKey:Boolean = false, altKey:Boolean = false, shiftKey:Boolean = false, pMouseSceneX:Number = NaN, pMouseSceneY:Number = NaN)
		{
			super(type, bubbles, cancelable) ;
			mInteractable = pTarget as ISceneInteractable;
			mSceneId = pSceneId ;
			
			mLocalX = localX ;
			mLocalY = localY ;
			mCtrlKey = ctrlKey ;
			mAltKey = altKey;
			mShiftKey = shiftKey;
			
			mSceneMouseX = pMouseSceneX ;
			mSceneMouseY = pMouseSceneY ;
		}
		
		/**
		 * The ISceneInteractable target of the event 
		 * @return the ISceneInteractable which triggered the event.
		 * 
		 */		
		public function get interactable():ISceneInteractable
		{
			return mInteractable as ISceneInteractable ;
		}
		
		/**
		 * The Scene id where the event came from. 
		 * @return Scene id of the scene 
		 * 
		 */		
		public function get sceneId():String
		{
			return mSceneId ;
		}

		public override function toString():String
		{
			return "SceneEvent "+ type + " from "+ mSceneId ;
		}

		/**
		 * Indicates whether the Alt key is active (true) or inactive (false). 
		 * Supported for Windows operating systems only.  
		 * @return 
		 * 
		 */		
		public function get altKey():Boolean
		{
			return mAltKey ;
		}
		
		/**
		 * On Windows, indicates whether the Ctrl key is active (true) or inactive (false). 
		 * On Macintosh, indicates whether either the Ctrl key or the Command key is activated.  
		 * @return 
		 * 
		 */		
		public function get ctrlKey():Boolean
		{
			return mCtrlKey ;
		}
		
		/**
		 * Indicates whether the Shift key is active (true) or inactive (false).  
		 * @return 
		 * 
		 */		
		public function get shiftKey():Boolean
		{
			return mShiftKey ;
		}
		
		/**
		 * The horizontal coordinate at which the event occurred relative to the containing sprite. 
		 * @return 
		 * 
		 */		
		public function get localX():Number
		{
			return mLocalX ;
		}
		
		/**
		 * The vertical coordinate at which the event occurred relative to the containing sprite. 
		 * @return 
		 * 
		 */		
		public function get localY():Number
		{
			return mLocalY ;
		}
		
		/**
		 * The horizontal coordinate on the scene at which the event occurred relative to the containing sprite. 
		 * @return 
		 * 
		 */		
		public function get sceneMouseX():Number
		{
			return mSceneMouseX ;
		}
		
		/**
		 * The vertical coordinate on the scene at which the event occurred relative to the containing sprite. 
		 * @return 
		 * 
		 */		
		public function get sceneMouseY():Number
		{
			return mSceneMouseY ;
		}
		
	}
}